var fs=require('fs');
var data='';

//创建可读流
var readFileStream=fs.createReadStream('input.txt');
readFileStream.setEncoding('utf8');
readFileStream.on('data',function(returndata){
	data+=returndata;
})
readFileStream.on('end',function(){
	console.log('读取的数据为======'+data);
})

//===================================================================
var data='这是我写入的数据哈\n';
var writeFileStram=fs.createWriteStream('input.txt');
writeFileStram.write(data,'utf8');
writeFileStram.end('========================结束=====');

writeFileStram.on('finish',function(){
	console.log('---------------------写入完成了------');
})
//=========================================================

var inStream=fs.createReadStream('input.txt');
var outStream=fs.createWriteStream('output.txt');
inStream.pipe(outStream);
console.log('-------管道流复制---');

//=======================链式流===================================
var zip=require('zlib');
var ins=fs.createReadStream('input.txt');
ins.pipe(zip.createGzip()).pipe(fs.createWriteStream('input.txt.gz'));
